package com.ycsj.goldmedalnewconcept.common.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.common.activity.HelpDetailsActivity;
import com.ycsj.goldmedalnewconcept.common.bean.HelpInfo;

import java.util.List;

/**
 * 公告列表列表适配器
 * Created by Administrator on 2018/6/20 0020.
 */

public class HelpItemRvAdapter extends BaseQuickAdapter<HelpInfo.DataBean.QaBean, BaseViewHolder> {

    private Context context;
    private LinearLayout.LayoutParams lp;

    public HelpItemRvAdapter(Context context, int layoutResId, @Nullable List<HelpInfo.DataBean.QaBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final HelpInfo.DataBean.QaBean item) {
//        //查看详情的布局
        RelativeLayout rl = helper.getView(R.id.rl_details);

        TextView tv_content = helper.getView(R.id.tv_content);

        tv_content.setText(item.getTitle());

        rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转到查看详情的界面
                Intent intent = new Intent(context, HelpDetailsActivity.class);
                intent.putExtra("url", item.getUrl());
                if(item.getType()==1){
                    intent.putExtra("title", "金牌君APP");
                }else{
                    intent.putExtra("title", "常见问题解决办法");
                }
                intent.putExtra("shareTitle", item.getTitle());
                context.startActivity(intent);
            }
        });
    }
}
